import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cloud.context.config.annotation.RefreshScope;

/**
 * ${TableComment}
 *
 * @author ${Author}  ${Email}
 * @since  ${DateTime}
 */
@Slf4j
@Service
@DubboService
@RefreshScope
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements ${ClassName}Service {


    @Override
    public CommonRespDTO<PagingRespDTO<${ClassName}DTO>> page(${ClassName}ReqDTO dto) {
       // 分页条件
       dto.setPageNum(dto.getPageNum() == null ? 1 : dto.getPageNum());
       dto.setPageSize(dto.getPageSize() == null ? 10 : dto.getPageSize());
       Page<${ClassName}> page = new Page<>(dto.getPageNum(), dto.getPageSize());

       // TODO 自定义Wrapper
       baseMapper.selectPage(page, null);

       List<${ClassName}DTO> dtos = convert.poToDtoList(page.getRecords());
       PagingRespDTO<I${ClassName}DTO> respDTO = new PagingRespDTO<>(page.getCurrent(), page.getSize(), page.getTotal(), dtos);
       return CommonRespDTO.success(respDTO);
    }


    @Override
    public CommonRespDTO<Boolean> save(${ClassName}DTO dto) {
       ${ClassName} po = ${ClassName}.builder()
       // TODO 建造者模式构建po
       .build();
       return baseMapper.insert(po) > 0 ? CommonRespDTO.success() : CommonRespDTO.error("新增失败");
    }


    @Override
    public CommonRespDTO<Boolean> removeById(String id) {
       return baseMapper.deleteById(id) > 0 ? CommonRespDTO.success() : CommonRespDTO.error("删除失败");
    }


    @Override
    public CommonRespDTO<Boolean> updateById(${ClassName}DTO dto) {
       ${ClassName} po = convert.dtoToPo(dto);
       return baseMapper.updateById(po) > 0 ? CommonRespDTO.success() : CommonRespDTO.error("更新失败");
    }


}